package learningThread.syn.synchronizedMethodLockObj.lock.readwritelock.readAndWrite;

/**
 * 读写互斥
 */
public class TestReadWrite {

    public static void main(String[] args) {
        final Service service = new Service();
        Thread threadA = new Thread(new Runnable() {
            @Override
            public void run() {
                service.read();
            }
        }, "threadA");

        Thread threadB = new Thread(new Runnable() {
            @Override
            public void run() {
                service.write();
            }
        }, "threadB");

        threadA.start();
        threadB.start();
    }
}
